package com.apes.fn.server.workOrder.repository;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.apes.framework.query.ApesDao;
import org.springframework.stereotype.Component;

/**
 * @program: apes-server
 * @description
 * @author: czs
 * @create: 2022-05-31 13:41
 **/
@Component
public class MaintenanceOrderDao extends ApesDao {

    /**
     * 传入询价单号,商品编码,供应商编码查询税率,不含税价
     * @param param
     * @return
     */
    public JSONArray queryTaxAndInTaxPrice(JSONObject param) {
        String sSQL = " select a.GYSSSBL,B.WSCGCKJ\n" +
                "           from PUR_GYSXJD A,PUR_GYSXJDMX B\n" +
                "       where a.XJDH = b.XJDH\n" +
                "           and a.XJDH = :XJDH\n" +
                "           AND B.SPID = :SPID\n" +
                "           and A.GYSID = :GYSID";

        return toJSONArray(find(sSQL, param));
    }
    /**
     * 传入唯一值 返回询价执行表数据
     * @param param
     * @return
     */
    public JSONArray querySpxjdByWYZ(JSONObject param) {
        String sSQL = "select *\n" +
                "      from PUR_SPXJD_ZXB a\n" +
                "      where WYZ = :WYZ";

        return toJSONArray(find(sSQL, param));
    }
    /**
     * 查询维修耗时
     * @param param
     * @return
     */
    public JSONArray queryProductHour(JSONObject param) {
        String sSQL = "select GET_WORK_TIME(A.POINT,\n" +
                "        A.WORKED_TIME,\n" +
                "        A.PAUSEED_TIME,\n" +
                "        A.POINT_START_TIME) WORKHOUR\n" +
                "      from SER_MAINTENANCE_ORDER_REPORT a\n" +
                "      where SERVICE_PLAN_I_ID = :plan_item_id";

        return toJSONArray(find(sSQL, param));
    }

}
